package com.demo.association.onetoone;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

@Entity
@Table(name = "AUTHER")
public class Auther {

	private int autherId;
	private String autherName;
	private String autherDegree;

	private Biography biography;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getAutherId() {
		return autherId;
	}

	@Column(name = "AUTHER_NAME")
	public String getAutherName() {
		return autherName;
	}

	@Column(name = "DEGREE")
	public String getAutherDegree() {
		return autherDegree;
	}
	@OneToOne(cascade=CascadeType.ALL)
	@PrimaryKeyJoinColumn  //auther primary key ---->foreign key ---- > biography primary key.
	public Biography getBiography() {
		return biography;
	}

	public void setBiography(Biography biography) {
		this.biography = biography;
	}

	public void setAutherId(int autherId) {
		this.autherId = autherId;
	}

	public void setAutherName(String autherName) {
		this.autherName = autherName;
	}

	public void setAutherDegree(String autherDegree) {
		this.autherDegree = autherDegree;
	}

	@Override
	public String toString() {
		return "Auther [autherId=" + autherId + ", autherName=" + autherName
				+ ", autherDegree=" + autherDegree + ", biography=" + biography
				+ "]";
	}

	
	
}
